package com.publish.file.service.auth;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

public class UserRoleDetail implements UserDetails {

	private static final long serialVersionUID = -3599935419541839320L;

	private ArrayList<RoleGrantedAuthority> roleGrantedAuthorityes = new ArrayList<RoleGrantedAuthority>();
	private String password;
	private String userName;

	public UserRoleDetail(String password, String userName) {
		super();
		this.password = password;
		this.userName = userName;
	}

	public void addRole(String role) {
		roleGrantedAuthorityes.add(new RoleGrantedAuthority(role));
	}

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return roleGrantedAuthorityes;
	}

	@Override
	public String getPassword() {
		return password;
	}

	@Override
	public String getUsername() {
		return userName;
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}

	@Override
	public String toString() {
		return "UserRoleDetail [roleGrantedAuthorityes=" + roleGrantedAuthorityes + ", password=" + password
				+ ", userName=" + userName + "]";
	}

}
